﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Collections;
using System.IO;

namespace Palsta.Core.Manifest
{
    class Manifest
    {
        #region Members

        private ArrayList caculations = new ArrayList();        //of Caculation
        private ArrayList customValidations = new ArrayList();  //of CustomValidation
        private ArrayList eventHandlers = new ArrayList();      //of EventHandlers
        private ArrayList ruleSets = new ArrayList();           //of RuleSet
        private ArrayList views = new ArrayList();              //of ViewDesc
        private String defaultView;

        #endregion

        #region Accessors

        public virtual ArrayList Caculations
        {
            get 
            {
                return this.caculations;
            }
            set
            {
                this.caculations = value;
            }
        }

        public virtual ArrayList CustomValidations
        {
            get
            {
                return this.customValidations;
            }
            set
            {
                this.customValidations = value;
            }
        }

        public virtual ArrayList EventHandlers
        {
            get
            {
                return this.eventHandlers;
            }
            set
            {
                this.eventHandlers = value;
            }
        }

        public virtual ArrayList RuleSets
        {
            get
            {
                return this.ruleSets;
            }
            set
            {
                this.ruleSets = value;
            }
        }

        public virtual ArrayList Views
        {
            get
            {
                return this.views;
            }
            set
            {
                this.views = value;
            }
        }


        public virtual String DefaultView
        {
            get
            {
                return this.defaultView;
            }
            set
            {
                this.defaultView = value;
            }
        }

        #endregion

        #region Methods
        public void AddCaculation(Caculation c)
        {
            this.caculations.Add(c);
        }

        public Caculation GetCaculation(String target)
        {
            foreach (Object c in this.caculations) 
            {
                if (c.Equals(target)) return (Caculation)c; 
            }
            return null;
        }


        public void AddCustomValidateions(CustomValidation cv)
        {
            this.customValidations.Add(cv);
        }

        public CustomValidation GetCustomValidateion(String target)
        {
            foreach (Object cv in this.customValidations)
            {
                if (cv.Equals(target)) return (CustomValidation)cv;
            }
            return null;
        }


        public void AddEventHandler(DomEventHandler eh)
        {
            this.eventHandlers.Add(eh);
        }

        public DomEventHandler GetEventHandler(String target)
        {
            foreach (Object eh in this.eventHandlers)
            {
                if (eh.Equals(target)) return (DomEventHandler)eh;
            }
            return null;
        }


        public void AddRuleSets(RuleSet r)
        {
            this.ruleSets.Add(r);
        }

        public RuleSet GetRuleSets(String target)
        {
            foreach (Object r in this.ruleSets)
            {
                if (r.Equals(target)) return (RuleSet)r;
            }
            return null;
        }

        #endregion

    }
}
